package com.dayu.web.controller.share;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.share.domain.ShareGoodsQuality;
import com.dayu.share.service.IShareGoodsQualityService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 商品成色Controller
 * 
 * @author HK
 * @date 2021-04-08
 */
@RestController
@RequestMapping("/share/quality")
public class ShareGoodsQualityController extends BaseController
{
    @Autowired
    private IShareGoodsQualityService shareGoodsQualityService;

    /**
     * 查询商品成色列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShareGoodsQuality shareGoodsQuality)
    {
        startPage();
        List<ShareGoodsQuality> list = shareGoodsQualityService.selectShareGoodsQualityList(shareGoodsQuality);
        return getDataTable(list);
    }

    /**
     * 导出商品成色列表
     */
    @PreAuthorize("@ss.hasPermi('share:quality:export')")
    @Log(title = "商品成色", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShareGoodsQuality shareGoodsQuality)
    {
        List<ShareGoodsQuality> list = shareGoodsQualityService.selectShareGoodsQualityList(shareGoodsQuality);
        ExcelUtil<ShareGoodsQuality> util = new ExcelUtil<ShareGoodsQuality>(ShareGoodsQuality.class);
        return util.exportExcel(list, "quality");
    }

    /**
     * 获取商品成色详细信息
     */
    @PreAuthorize("@ss.hasPermi('share:quality:query')")
    @GetMapping(value = "/{qualityId}")
    public AjaxResult getInfo(@PathVariable("qualityId") Long qualityId)
    {
        return AjaxResult.success(shareGoodsQualityService.selectShareGoodsQualityById(qualityId));
    }

    /**
     * 新增商品成色
     */
    @PreAuthorize("@ss.hasPermi('share:quality:add')")
    @Log(title = "商品成色", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareGoodsQuality shareGoodsQuality)
    {
        return toAjax(shareGoodsQualityService.insertShareGoodsQuality(shareGoodsQuality));
    }

    /**
     * 修改商品成色
     */
    @PreAuthorize("@ss.hasPermi('share:quality:edit')")
    @Log(title = "商品成色", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShareGoodsQuality shareGoodsQuality)
    {
        return toAjax(shareGoodsQualityService.updateShareGoodsQuality(shareGoodsQuality));
    }

    /**
     * 删除商品成色
     */
    @PreAuthorize("@ss.hasPermi('share:quality:remove')")
    @Log(title = "商品成色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{qualityIds}")
    public AjaxResult remove(@PathVariable Long[] qualityIds)
    {
        return toAjax(shareGoodsQualityService.deleteShareGoodsQualityByIds(qualityIds));
    }
}
